package com.hustzp.com.xichuangzhu.utils;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hustzp.com.xichuangzhu.R;

/**
 * Created by My on 2016/6/5.
 */
public class DialogFactory {

    public static Dialog createLoadingDialog(Context context, String msg) {

        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.layout_dialog, null);// 得到加载view
        TextView tipTextView = (TextView) v.findViewById(R.id.tvMsg);// 提示文字
        tipTextView.setText(msg);// 设置加载信息
        Dialog dialog = new Dialog(context, R.style.LoadingDialogStyle);
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);// 不可以用“返回键”取消
        dialog.setContentView(v, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.FILL_PARENT));// 设置布局
        dialog.show();
        return dialog;
    }

    public static Dialog hintDialog(Context context, String msg) {

        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.hint_dialog, null);// 得到加载view
        TextView tipTextView = (TextView) v.findViewById(R.id.tvMsg);// 提示文字
        tipTextView.setText(msg);// 设置加载信息
        final Dialog dialog = new Dialog(context, R.style.LoadingDialogStyle);
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);// 不可以用“返回键”取消
        dialog.setContentView(v, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.FILL_PARENT));// 设置布局
        v.findViewById(R.id.sure_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
        return dialog;
    }
    public static Dialog verifyCodeMenu(Context context) {

        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.verify_code_menu, null);// 得到加载view
        final Dialog dialog = new Dialog(context, R.style.LoadingDialogStyle);
        dialog.setCanceledOnTouchOutside(true);
        dialog.setContentView(v, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.FILL_PARENT));// 设置布局
         v.findViewById(R.id.cancle_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.getWindow().setGravity(Gravity.BOTTOM);
        dialog.show();
        return dialog;

    }
}
